package com.spring.service.impl;

import com.spring.VO.User;
import com.spring.dao.myProTest.UserDao;
import com.spring.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService{

    @Autowired
    UserDao userDao;

    @Override
    public User login(String username, String password) {
        return userDao.findUser(username, password);
    }

    @Override
    public boolean register(String username, String password) {
        User result = userDao.findByName(username);
        if (result != null) {
            return false;
        }
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        int re = userDao.createUser(user);
        return re == 1;
    }
}
